{block name="main"}
<div class="tab-content pt-15">
    <div class="tab-pane fade tab-1 active in" id="base_info">
        <form class="form-horizontal form-validate-1 widthFixedForm">
            <div class="form-heading">开发者信息</div>
            <div class="form-group">
                <label class="col-md-2 control-label">AppID</label>
                <div class="col-md-5">
                    <p class="form-control-static" id = "app_id"></p>
                </div>
            </div>

            <div class="form-group">
                <label class="col-md-2 control-label"><span class="text-bright">*</span>AppSecret</label>
                <div class="col-md-5">
                    <input type="text" class="form-control" id="app_secret" name="app_secret">
                    <p class="help-block">访问微信公众平台=》开发=》开发设置获取AppSecret。</p>
                </div>
            </div>
            <div class="form-group">
                <label class="col-md-2 control-label"></label>
                <div class="col-md-8">
                    <a class="btn btn-primary auth" href="javascript:void(0);">授权完成</a>
<!--                    <button class="btn btn-primary custom" type="submit">前往装修</button>-->
                </div>
            </div>
        </form>
    </div>
</div>
{/block}
{block name="script"}
<script>
    require(['util'], function (util) {

        // 授权app_secret
        $(".auth").click(function () {
            var app_secret = $("#app_secret").val();
            if (app_secret == '') {
                util.message('AppSecret不能为空');
                return false;
            }
            $.ajax({
                type: 'POST',
                url: '{$saveMpAppSecretUrl}',
                data: {
                    'app_secret': app_secret,
                },
                success: function (data) {
                    console.log(data);
                    if (data['code'] > 0) {
                        util.message(data["message"], 'success');
                        location.href = __URL('ADDONS_MAINminiProgramSetting');
                    } else {
                        util.message(data["message"], 'danger');
                    }
                }
            });
        })
        // 装修
        // $(".custom").click(function () {
        //     location.href = __URL('ADDONS_MAINminiProgramCustomList');
        // })
        //
        // util.validate($('.form-validate-1'), function (form) {
        //
        // })

        LoadingInfo();
        function LoadingInfo() {
            $.ajax({
                type: "post",
                url: "{$getMpAppIdUrl}",
                success: function (data) {
                    $("#app_id").html(data.message);
                }
            });
        }

    })

</script>
{/block}
